package com.hd.trans.framework.dialog;


import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hd.trans.R;
import com.hd.trans.db.bean.HuDunLanguage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

/**
 * Desc: 识别语种item,翻译目标语种item
 */
public class TransLanguageAdapter extends BaseQuickAdapter<HuDunLanguage, BaseViewHolder> {

    private HuDunLanguage checkedItem;

    public TransLanguageAdapter(@Nullable List<HuDunLanguage> data) {
        super(R.layout.item_trans_lang, data);
    }

    public void setCheckedItem(HuDunLanguage item) {
        if (checkedItem != item) {
            checkedItem = item;
            notifyDataSetChanged();
        }
    }

    public HuDunLanguage getCheckedItem() {
        return checkedItem;
    }

    @Override
    protected void convert(BaseViewHolder helper, HuDunLanguage item) {

        if (item != null) {
            boolean flag = item.getName().equals(checkedItem.getName());
            helper.setVisible(R.id.img_check_lang, flag);
            helper.getView(R.id.rl_item_lang).setSelected(flag);

            helper.setText(R.id.txt_name_lang,item.getName());
        }
    }

}
